import unittest, requests


class Keji(unittest.TestCase):
    def setUp(self) -> None:
        print('start case')

    def tearDown(self) -> None:
        print('end case')

    host = 'https://10.59.9.18'

    # 登录
    userId = None
    sessionId = None

    def test_keji_01(self):
        login = requests.post(url=Keji.host + '/techApi/user/v1/login', verify=False,
                              data={'phone': '15535738378',
                                    'pwd': 'S0hBZElnMkExQml6T21vYVRacVNmN2lSRHUxNGVsK2JMSXlBUkpWSmJsM0JJYkN0M0RYaTZLMDh0N3pLSU1FYzgvR1FFZzhZMExYaXFqNWE1WlBiUGd4bWdYWFVvZ09VTzdYcmpZOUZRRStqUkhqN1RVc25GSDJvaWp1STI3Tm1WdWpDdlRZTUpGVit5WGRMOTZlZlY3eTlKWVJENzlIdzlPN2xNMWQ5eUEwPQ'})
        print(login.json())
        Keji.userId = login.json()['result']['userId']
        Keji.sessionId = login.json()['result']['sessionId']

    # 查询用户的好友通知记录
    remark=None
    def test_keji_02(self):
        header = {'userId': str(Keji.userId), 'sessionId': str(Keji.sessionId)}
        data = {'status': 2, 'page': 1,'count':5}
        addFriend = requests.get(url=Keji.host + '/techApi/chat/verify/v1/findFriendNoticePageList', verify=False,
                                  headers=header, params=data)
        print(addFriend.json())
        # 提取 remark
        Keji.remark=addFriend.json()['result'][0]['remark']
        print(Keji.remark)

    # 添加好友
    def test_keji_03(self):
        header = {'userId': str(Keji.userId), 'sessionId': str(Keji.sessionId)}
        data = {'friendUid': 352, 'remark': str(Keji.remark)}
        addFriend = requests.post(url=Keji.host + '/techApi/chat/verify/v1/addFriend', verify=False,
                                  headers=header, data=data)
        print(addFriend.json())

    # 初始化我的好友列表全量信息
    commodityId = None

    def test_keji_04(self):
        header = {'userId': str(Keji.userId), 'sessionId': str(Keji.sessionId)}
        FriendList = requests.get(url=Keji.host + '/techApi/chat/verify/v1/initFriendList', verify=False,
                                  headers=header)
        print(FriendList.json())

    # 检测是否为我的好友
    def test_keji_05(self):
        header = {'userId': str(Keji.userId), 'sessionId': str(Keji.sessionId)}
        data = {'friendUid':352}
        MyFriend = requests.get(url=Keji.host + '/techApi/chat/verify/v1/checkMyFriend', verify=False,
                                  headers=header,params=data)
        print(MyFriend.json())


if __name__ == '__main__':
    unittest.main()
